import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import 'package:fluttertoast/fluttertoast.dart';
import '../../services/event_bus.dart';

class ProductBottom extends StatefulWidget {
  ProductBottom({this.productValue});

  final List<dynamic> productValue;

  @override
  _ProductBottomState createState() => _ProductBottomState();
}

class _ProductBottomState extends State<ProductBottom> {

  collect(){

  }


  @override
  Widget build(BuildContext context) {
    return Container(
      padding: EdgeInsets.symmetric(vertical: 15.w,horizontal: 10.w),
      decoration: BoxDecoration(
          border: Border(top: BorderSide(color: Colors.black12, width: 1)),
          color: Colors.white),
      child: Row(
        mainAxisAlignment: MainAxisAlignment.center,
        mainAxisSize: MainAxisSize.max,
        children: <Widget>[
          InkWell(
            onTap: () {
              collect();
            },
            child: Container(
              padding: EdgeInsets.only(top: 4.h),
              width: 120.sp,
              height: 84.h,
              child: Column(
                children: <Widget>[
                  Icon(Icons.favorite, size: 36.sp),
                  Text("收藏", style: TextStyle(fontSize: 22.sp))
                ],
              ),
            ),
          ),
          InkWell(
            onTap: () {
              Navigator.of(context).pushNamed('/cart');
            },
            child: Container(
              padding: EdgeInsets.only(top: 4.h),
              width: 120.sp,
              height: 84.h,
              child: Column(
                children: <Widget>[
                  Icon(Icons.shopping_cart, size: 36.sp),
                  Text("购物车", style: TextStyle(fontSize: 22.sp))
                ],
              ),
            ),
          ),
          Expanded(
            child:Container(
              height:80.w,
              child:  FlatButton(
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.only(topLeft:Radius.circular(20),bottomLeft: Radius.circular(20))
                ),
                color: Color.fromRGBO(255, 165, 0, 0.9),
                child: Text(
                  "加入购物车",
                  style: TextStyle(color: Colors.white, fontSize: 24.sp),
                ),
                onPressed: () async {
                  if (widget.productValue.length > 0) {
                    //广播 弹出筛选
                    eventBus.fire(new ProductContentEvent('加入购物车'));
                  } else {
                    Fluttertoast.showToast(
                      msg: '加入购物车成功',
                      toastLength: Toast.LENGTH_SHORT,
                      gravity: ToastGravity.CENTER,
                    );
                  }
                },
              ),
            ),
          ),
          Expanded(
            child: Container(
              height:80.w,
              child: FlatButton(
                shape: RoundedRectangleBorder(
                    borderRadius: BorderRadius.only(topRight:Radius.circular(20),bottomRight: Radius.circular(20))
                ),
                color: Color.fromRGBO(253, 1, 0, 0.9),
                child: Text(
                  "立即购买",
                  style: TextStyle(color: Colors.white, fontSize: 24.sp),
                ),
                onPressed: () {
                  if (widget.productValue.length > 0) {
                    //广播 弹出筛选
                    eventBus.fire(new ProductContentEvent('立即购买'));
                  } else {
                    print("立即购买");
                  }
                },
              ),
            ),
          )
        ],
      ),
    );
  }
}
